﻿using System;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Web.UI.WebControls;

public partial class _Estatisticas : System.Web.UI.Page
{
    int nAtividades = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SqlConnection conexaoIntranet = new SqlConnection(ConfigurationManager.ConnectionStrings["conexao_intranet"].ConnectionString);
            SqlDataReader drNInscritos;
            try
            {
                if (conexaoIntranet != null && conexaoIntranet.State != ConnectionState.Open)
                    conexaoIntranet.Open();
                SqlCommand consultaNInscritos = new SqlCommand();
                consultaNInscritos.Connection = conexaoIntranet;
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblQtdeRegistros.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();
                consultaNInscritos.CommandText = "select count(*) as NInscritos from camarainscritos where datacadastro between '08-18-2012 00:00:01' and '08-18-2012 23:59:59'";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblQtdeRegistros.Text += "&nbsp;&nbsp;|&nbsp; Feira das Profissões: " + drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** capacitação **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE Capacitacao = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblCap.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** aperfeiçoamento **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE Aperfeicoamento = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblAperf.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** informática **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE Informatica = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblInfo.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** idiomas **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE Idioma = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblIdiomas.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** atividades complementares **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE AtivComplementares = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblAtivCom.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** aprendiz **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE Aprendiz = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblAprendiz.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

                //************** experiência **************//
                consultaNInscritos.CommandText = "SELECT COUNT(*) as NInscritos FROM CamaraInscritos WHERE Experiencia = 1";
                drNInscritos = consultaNInscritos.ExecuteReader();
                drNInscritos.Read();
                lblExp.Text = drNInscritos["NInscritos"].ToString();
                drNInscritos.Close();

            }
            finally
            {
                conexaoIntranet.Close();
            }
        }


    }
}